package fr.enac;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class JoggingActivity extends Activity implements OnClickListener {
	/** Called when the activity is first created. */

	private Button startButton;
	private Button stopButton;
	private Button backToMenuButton;
	private static enum TextStartButton{
		START,
		PAUSE
	}
	private TextStartButton currentTextStartButton = TextStartButton.START;
	private static enum TextStopButton {
		STOP,
		SAVE,
		UPLOADED};
	private TextStopButton currentTextStopButton = TextStopButton.STOP;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		setContentView(R.layout.main);

		startButton = (Button) findViewById(R.id.button2);
		stopButton = (Button) findViewById(R.id.button3);
		backToMenuButton = (Button) findViewById(R.id.button1);

		/* METHODE 1 :  */
		startButton.setOnClickListener(this);
		stopButton.setOnClickListener(this);
		backToMenuButton.setOnClickListener(this);

		
	}

	public void mettreEnPause(){
		switch (currentTextStartButton){
		case START :
			startButton.setText("Pause");
			currentTextStartButton = TextStartButton.PAUSE;
			break;
		case PAUSE :
			startButton.setText("Start");
			currentTextStartButton = TextStartButton.START;
			break;
		default :
			break;
		}
		
	}

	public void arreter(){
		switch (currentTextStopButton){
		case STOP : 
			stopButton.setText("Save");
			currentTextStopButton = TextStopButton.SAVE;
		break;
		case SAVE : 
			stopButton.setText("uploaded");
			currentTextStopButton = TextStopButton.UPLOADED;
		break;
		default : 
			break;
		}
	}
	
	public void retourAuMenuPrincipal(){
		Intent intent3 = new Intent(JoggingActivity.this, Menu.class);
		startActivity(intent3);
	}

	public void onClick(View v){
		switch (v.getId()) {
		case R.id.button2:
			mettreEnPause();
			break;
		case R.id.button3:
			arreter();
			break;
		case R.id.button1 :
			retourAuMenuPrincipal();
			break;
		default:
			break;
		}

	}
}
